This repository has been archived by the owner on Nov 3, 2022. It is now read-only.
added reduction_utils.py in the utils directory for 'model surgery' #309
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This utility is an add on to Keras to perform model 'surgery'. The utility provides functions to modify the model json and saved model h5 definition to restructure and rearrange the model architecture kernels, WITHOUT retraining.
The current version is tested with Tensorflow and Theano on python 3.5 and 3.6. Testing wasn't done with CNTK
It is recommended to copy the model h5 file before performing model surgery using the following command:
h5repack -i <model_h5_file> -o <new_model_h5_file>
and run the provided functions on the new h5 file generated. The docstrings provide full description of the method functionality but in case of assistance, please reach out to me via github.
REDUCTION_UTILS:
reduction_utils.py can be used to prune or modify the model architecture. The flexibility of changing kernel matrices, not just removing them enables advanced pruning methods like cosine similarity based pruning (included in reduction_utils.py), correlation coffecient based pruning and just average percentage of zeros pruning methods.
Along with the addition of reduction utils, changes has been made to keras_contrib/layers/convolutional.py. For details, see this fix (#292):
#292